package com.laicunba.ext.web.controller.console;

import org.aspectj.internal.lang.annotation.ajcDeclareAnnotation;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.laicunba.ext.web.controller.BaseController;
import com.laicunba.ext.web.init.PropertiesInit;
import com.laicunba.pojo.ActionDO;
import com.laicunba.service.ActionService;

@Controller
@RequestMapping(value = "/console/ext")
public class SynActionTabController extends BaseController {

	@Autowired
	private ActionService actionService;

	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(value = "/synActionTab.htm")
	public String synActionTab() {
		JSONObject json = new JSONObject();
		ActionDO actionDO = null;
		for (String id : PropertiesInit.CONSOLE_URI.keySet()) {
			actionDO = actionService.get(ActionDO.class, id);
			if (actionDO != null) {
				continue;
			}
			actionDO = new ActionDO();
			actionDO.setId(id);
			actionDO.setUri(PropertiesInit.CONSOLE_URI.get(id));
			actionService.create(actionDO);
			json.put(id, actionDO.getUri());
		}
		json.put("code", "syn action tab ok.");
		return json.toJSONString();
	}
}
